﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
        public class YAB50AV95Report : BaseReport
    {
            string strCompany = "HLT",strExcelFile = "";
            public string StandardType = "";
        public YAB50AV95Report()
            : base()
        {
        }
        public YAB50AV95Report(Dictionary<string, object> dicParamater)
            : base(dicParamater)
        {
            columns.Add("STATUS"); 
            columns.Add("ABPSTARTDAT"); 
            columns.Add("DFACTORY"); 
            columns.Add("WEI"); 
            columns.Add("DORDERNO"); 
            columns.Add("YARN"); 
            columns.Add("YARNDES"); 
            columns.Add("COLOR"); 
            columns.Add("COLORDES"); 
            columns.Add("USAGE"); 
            columns.Add("ARTICLE"); 
            columns.Add("LASTDAT"); 
            columns.Add("ISSWEI"); 
            columns.Add("RECDAT"); 
            columns.Add("RECWEI");
            columns.Add("ENDDAT");
            columns.Add("REMARK");
            strCompany = dicParamater["Company"].ToString().Trim();
            strExcelFile = dicParamater["ExcelFile"].ToString().Trim();
            
        }
        public void FillInExcelData(ArrayList columns, DataSet setSoruce, int xStart = 2, int yStart = 1)
        {
            try
            {               
                int x = xStart, y = yStart;
                DataTable dtSoruce = setSoruce.Tables["YABPOS"];
                foreach (DataRow dataRow in dtSoruce.Rows)
                {
                    y = yStart;
                    foreach (string column in columns)
                    {
                        exAgent.SetCellValue(x, y, dataRow[column].ToString());
                        y++;
                    }
                    x++;
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public void WriteExcelReport(string fileType)
        {
            Queue CellQueue = new Queue();

            string filename = "";
            string sheetName = "";
            string Standard = "YAB50AV95";
            strExcelFile = @"HLT\HLTPlanningReport.xls";
            string filePath = @"C:\intex.w\Report\" + strExcelFile;
            exAgent.Open(filePath);
            exAgent.Company = strCompany;
            exAgent.strExcelFile = strExcelFile;
            string filedate = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
            filename = @"Planning\染色\染色订单进度" + filedate + ".xls";
            sheetName = DateTime.Now.ToShortTimeString().Replace(@":", "");
            exAgent.CreateNewSheet(filename, Standard, sheetName);
            FillInExcelData(columns, dsSource, 3, 1);
            base.WriteExcelReport(fileType);
            
        }
    }

}
